using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Dogfight2008.Common
{
  public class ColoredPolygonMesh : IEnumerable<ColoredPolygon>
  {
    public readonly FixedList<ColoredPolygon> Polygons;

    public ColoredPolygonMesh(IEnumerable<ColoredPolygon> polygons)
    {
      Polygons = new FixedList<ColoredPolygon>(polygons);
    }

    public ColoredPolygonMesh(params ColoredPolygon[] polygons)
    {
      Polygons = new FixedList<ColoredPolygon>(polygons);
    }

    public override string ToString()
    {
      return string.Format("{0} polygon mesh", Polygons.Count);
    }

    public override bool Equals(object obj)
    {
      ColoredPolygonMesh rhs = obj as ColoredPolygonMesh;
      if (rhs == null)
        return false;

      return Polygons.Equals(rhs.Polygons);
    }

    public override int GetHashCode()
    {
      unchecked
      {
        return Polygons.GetHashCode();
      }
    }

    #region IEnumerable Members

    public IEnumerator GetEnumerator()
    {
      return Polygons.GetEnumerator();
    }

    IEnumerator<ColoredPolygon> IEnumerable<ColoredPolygon>.GetEnumerator()
    {
      return Polygons.GetEnumerator();
    }

    #endregion
  }
}
